import React from 'react'
import { useEffect } from 'react'
import { useState } from 'react'

export default function App() {
  let [Person, setPerson] = useState([
    { id: '001', name: '张三' },
    { id: '002', name: '李四' },
    { id: '003', name: '王五' },
  ])

  useEffect(() => {
    console.log('person改变了');
  }, [Person])

  const addperson = () => {
    setPerson([...Person,{id:Date.now(),name:'熬夜波比'}])
  }
  return (
    <div>
      <button onClick={addperson}>添加数据</button>
      <ul>
        {
          Person.map(item => {
            return <li key={item.id}>{item.name}</li>
          })
        }
      </ul>
    </div>
  )
}
